﻿/*
Copyright © 2011 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See <license.txt> for the complete license of the software.
*/

using Microsoft.Phone.Controls;
using System.Windows;

namespace NUnit.Phone.Gui
{
    /// <summary>
    /// Displays the result of a test execution.
    /// </summary>
    public partial class ResultList : Panorama
    {
        /// <summary>
        /// Initializes a new instance of the ResultList class.
        /// </summary>
        public ResultList()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// Changes the disposition of the elements based on the current orientation
        /// before displaying the control.
        /// </summary>
        /// <param name="availableSize">The available size.</param>
        /// <returns>The used size.</returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            PhoneApplicationPage page = this.RetrieveParent<PhoneApplicationPage>();
            if ((page.Orientation & PageOrientation.Landscape) == PageOrientation.Landscape)
            {
                this.resultVertical.Visibility = Visibility.Collapsed;
                this.resultHorizontal.Visibility = Visibility.Visible;
            }
            else
            {
                this.resultVertical.Visibility = Visibility.Visible;
                this.resultHorizontal.Visibility = Visibility.Collapsed;
            }

            return base.MeasureOverride(availableSize);
        }
    }
}
